{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "124e9cf8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pathlib\n",
    "original_file_path = pathlib.Path(\"original\")\n",
    "original_file_path.exists()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fe665b59",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Created target/ReportRequest.md from original/ReportRequest.txt\n",
      "Created target/BlogMapper.md from original/BlogMapper.txt\n",
      "Created target/MailServiceImpl.md from original/MailServiceImpl.txt\n",
      "Created target/BanBlock.md from original/BanBlock.txt\n",
      "Created target/StockController.md from original/StockController.txt\n",
      "Created target/ComplaintController.md from original/ComplaintController.txt\n",
      "Created target/LoginController.md from original/LoginController.txt\n",
      "Created target/ProductToGoodTransaction.md from original/ProductToGoodTransaction.txt\n",
      "Created target/MailService.md from original/MailService.txt\n",
      "Created target/ErrandOrderStatus.md from original/ErrandOrderStatus.txt\n",
      "Created target/ComplaintServiceImpl.md from original/ComplaintServiceImpl.txt\n",
      "Created target/ComplaintMapper.md from original/ComplaintMapper.txt\n",
      "Created target/RegisterServiceImpl.md from original/RegisterServiceImpl.txt\n",
      "Created target/BanMapper.md from original/BanMapper.txt\n",
      "Created target/ApiInterceptor.md from original/ApiInterceptor.txt\n",
      "Created target/SessionKeys.md from original/SessionKeys.txt\n",
      "Created target/Reply.md from original/Reply.txt\n",
      "Created target/RegisterRequest.md from original/RegisterRequest.txt\n",
      "Created target/LocalUploadFileSystemService.md from original/LocalUploadFileSystemService.txt\n",
      "Created target/AlipayConfigMapper.md from original/AlipayConfigMapper.txt\n",
      "Created target/RegisterController.md from original/RegisterController.txt\n",
      "Created target/GoodMapper.md from original/GoodMapper.txt\n",
      "Created target/UserController.md from original/UserController.txt\n",
      "Created target/ProductTransaction.md from original/ProductTransaction.txt\n",
      "Created target/CampusAidException.md from original/CampusAidException.txt\n",
      "Created target/Shop.md from original/Shop.txt\n",
      "Created target/UserMapper.md from original/UserMapper.txt\n",
      "Created target/Blog.md from original/Blog.txt\n",
      "Created target/GoodTransaction.md from original/GoodTransaction.txt\n",
      "Created target/ShopMapper.md from original/ShopMapper.txt\n",
      "Created target/LikeBlog.md from original/LikeBlog.txt\n",
      "Created target/ComplaintService.md from original/ComplaintService.txt\n",
      "Created target/ErrandMapper.md from original/ErrandMapper.txt\n",
      "Created target/UploadFileSystemService.md from original/UploadFileSystemService.txt\n",
      "Created target/ForumPostServiceImpl.md from original/ForumPostServiceImpl.txt\n",
      "Created target/ForumPostPreview.md from original/ForumPostPreview.txt\n",
      "Created target/ExceptionServiceImpl.md from original/ExceptionServiceImpl.txt\n",
      "Created target/LoginRequest.md from original/LoginRequest.txt\n",
      "Created target/StockService.md from original/StockService.txt\n",
      "Created target/KeywordType.md from original/KeywordType.txt\n",
      "Created target/Visibility.md from original/Visibility.txt\n",
      "Created target/User.md from original/User.txt\n",
      "Created target/BaseAuthService.md from original/BaseAuthService.txt\n",
      "Created target/Errand.md from original/Errand.txt\n",
      "Created target/ReplyView.md from original/ReplyView.txt\n",
      "Created target/ErrandServiceImpl.md from original/ErrandServiceImpl.txt\n",
      "Created target/ErrandInterceptorTemplated.md from original/ErrandInterceptorTemplated.txt\n",
      "Created target/ShopInfo.md from original/ShopInfo.txt\n",
      "Created target/ShopOrder.md from original/ShopOrder.txt\n",
      "Created target/AlipayTemplate.md from original/AlipayTemplate.txt\n",
      "Created target/ErrandViewsMapper.md from original/ErrandViewsMapper.txt\n",
      "Created target/ChargeMapper.md from original/ChargeMapper.txt\n",
      "Created target/ReplyMapper.md from original/ReplyMapper.txt\n",
      "Created target/OrderMapper.md from original/OrderMapper.txt\n",
      "Created target/AlipayController.md from original/AlipayController.txt\n",
      "Created target/ComplaintBlock.md from original/ComplaintBlock.txt\n",
      "Created target/ForumPostService.md from original/ForumPostService.txt\n",
      "Created target/ReplyMapperStruct.md from original/ReplyMapperStruct.txt\n",
      "Created target/BlogToForumPostPreview.md from original/BlogToForumPostPreview.txt\n",
      "Created target/ExceptionMapper.md from original/ExceptionMapper.txt\n",
      "Created target/RegisterService.md from original/RegisterService.txt\n",
      "Created target/ReplyTreeConverter.md from original/ReplyTreeConverter.txt\n",
      "Created target/BanInterceptor.md from original/BanInterceptor.txt\n",
      "Created target/ExceptionService.md from original/ExceptionService.txt\n",
      "Created target/ChargeServiceImpl.md from original/ChargeServiceImpl.txt\n",
      "Created target/ComplaintDTOMapper.md from original/ComplaintDTOMapper.txt\n",
      "Created target/UserService.md from original/UserService.txt\n",
      "Created target/PostSortOrder.md from original/PostSortOrder.txt\n",
      "Created target/ErrorController.md from original/ErrorController.txt\n",
      "Created target/ChargeService.md from original/ChargeService.txt\n",
      "Created target/VerifyRequest.md from original/VerifyRequest.txt\n",
      "Created target/GlobalExceptionHandler.md from original/GlobalExceptionHandler.txt\n",
      "Created target/Complaint.md from original/Complaint.txt\n",
      "Created target/TemplatedBanInterceptor.md from original/TemplatedBanInterceptor.txt\n",
      "Created target/ApiResponse.md from original/ApiResponse.txt\n",
      "Created target/Good.md from original/Good.txt\n",
      "Created target/UserServiceImpl.md from original/UserServiceImpl.txt\n",
      "Created target/ErrandOrderPreview.md from original/ErrandOrderPreview.txt\n",
      "Created target/TransactionMapper.md from original/TransactionMapper.txt\n",
      "Created target/ShopService.md from original/ShopService.txt\n",
      "Created target/AuthInterceptor.md from original/AuthInterceptor.txt\n",
      "Created target/ForumController.md from original/ForumController.txt\n",
      "Created target/LoginService.md from original/LoginService.txt\n",
      "Created target/ErrandService.md from original/ErrandService.txt\n",
      "Created target/ViewInterceptor.md from original/ViewInterceptor.txt\n",
      "Created target/ShopController.md from original/ShopController.txt\n",
      "Created target/WebConfig.md from original/WebConfig.txt\n",
      "Created target/ErrandController.md from original/ErrandController.txt\n",
      "Created target/ErrandOrderRequest.md from original/ErrandOrderRequest.txt\n",
      "Created target/ForumInterceptorTemplated.md from original/ForumInterceptorTemplated.txt\n",
      "Created target/ShopServiceImpl.md from original/ShopServiceImpl.txt\n",
      "Created target/ReplyTreeNode.md from original/ReplyTreeNode.txt\n",
      "Created target/LikeBlogMapper.md from original/LikeBlogMapper.txt\n",
      "Created target/ComplaintRequest.md from original/ComplaintRequest.txt\n",
      "Created target/SecurityProperties.md from original/SecurityProperties.txt\n",
      "Created target/StockServiceImpl.md from original/StockServiceImpl.txt\n",
      "Created target/AdminConfig.md from original/AdminConfig.txt\n",
      "Created target/Ban.md from original/Ban.txt\n",
      "Created target/OrderDTO.md from original/OrderDTO.txt\n",
      "Created target/Order.md from original/Order.txt\n",
      "Created target/LoginServiceImpl.md from original/LoginServiceImpl.txt\n",
      "Created target/Charge.md from original/Charge.txt\n",
      "Created target/BasicInterceptor.md from original/BasicInterceptor.txt\n",
      "Created target/CampusAidApplication.md from original/CampusAidApplication.txt\n"
     ]
    }
   ],
   "source": [
    "target_directory = pathlib.Path(\"target\")\n",
    "target_directory.mkdir(parents=True, exist_ok=True)\n",
    "for original_file in original_file_path.rglob(\"*.md\"):\n",
    "    name= original_file.name.split(\".\")[0]\n",
    "    with open(original_file, \"r\") as file:\n",
    "        content = file.read()\n",
    "    content = content.replace(\"class 1\",name).replace(\"class1\",name)\n",
    "    target_file = target_directory / f\"{name}.md\"\n",
    "    with open(target_file, \"w\") as file:\n",
    "        file.write(content)\n",
    "    print(f\"Created {target_file} from {original_file}\")    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cd4c7c42",
   "metadata": {},
   "outputs": [],
   "source": [
    "for file in target_directory.rglob(\"*.md\"):\n",
    "    name = file.name.split(\".\")[0]\n",
    "    with open(file, \"r\") as f:\n",
    "        content = f.read()\n",
    "    content = content.replace(\"class 1\", f\"`{name}`\").replace(\"class1\", f\"`{name}`\")\n",
    "    with open(file, \"w\") as f:\n",
    "        f.write(content)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
